using DG.Tweening;
using UnityEngine;

public class GameSceneController : MonoBehaviour
{
	private static GameSceneController _mInstance;

	public Transform _Tsf_Player;

	public Transform _Tsf_CameraPos;

	public Camera _Camera;

	public Transform _Tsf_背景层远1;

	public Transform _Tsf_背景层远;

	public Transform _Tsf_背景层近;

	public Transform _Tsf_场景层;

	public Transform _Tsf_前景层;

	public Transform _Tsf_左边界;

	public Transform _Tsf_右边界;

	public bool _保持中间;

	private float _CameraMaxX;

	private float _CameraMinX;

	public static void F_屏幕震动(float 持续时间 = 0.5f, float 震动幅度 = 0.1f, int 震动频率 = 10)
	{
		if (_mInstance != null && _mInstance._Camera != null)
		{
			_mInstance._Camera.transform.localPosition = Vector3.zero;
			_mInstance._Camera.DOShakePosition(持续时间, 震动幅度, 震动频率);
		}
	}

	private void Start()
	{
		_mInstance = this;
		float num = Camera.main.orthographicSize * Camera.main.aspect;
		_保持中间 = false;
		_CameraMinX = _Tsf_左边界.position.x + num;
		_CameraMaxX = _Tsf_右边界.position.x - num;
		float num2 = _Tsf_右边界.position.x - _Tsf_左边界.position.x;
		if (num * 2f >= num2)
		{
			_保持中间 = true;
			_Tsf_CameraPos.position = new Vector3((_Tsf_右边界.position.x + _Tsf_左边界.position.x) / 2f, 0f, -15f);
		}
	}

	private void OnDestroy()
	{
		_mInstance = null;
	}

	private void LateUpdate()
	{
		if (_保持中间)
		{
			return;
		}
		if (_Tsf_Player == null)
		{
			GameObject gameObject = GameObject.FindGameObjectWithTag("Player");
			if (gameObject != null)
			{
				_Tsf_Player = gameObject.transform;
			}
			return;
		}
		float num = _Tsf_Player.position.x;
		if (num < _CameraMinX)
		{
			num = _CameraMinX;
		}
		else if (num > _CameraMaxX)
		{
			num = _CameraMaxX;
		}
		_Tsf_CameraPos.position = new Vector3(num, 0f, -15f);
		F_前景层(num);
		F_背景层近(num);
		F_背景层远(num);
		F_背景层远1(num);
	}

	private void F_前景层(float playerX)
	{
		float x = (0f - playerX) * 0.2f;
		_Tsf_前景层.position = new Vector2(x, 0f);
	}

	private void F_背景层近(float playerX)
	{
		float x = (0f - playerX) * 0.12f;
		_Tsf_背景层近.position = new Vector2(x, 0f);
	}

	private void F_背景层远(float playerX)
	{
		float x = (0f - playerX) * 0.05f;
		_Tsf_背景层远.position = new Vector2(x, 0f);
	}

	private void F_背景层远1(float playerX)
	{
		float x = (0f - playerX) * 0f;
		_Tsf_背景层远1.position = new Vector2(x, 0f);
	}
}
